﻿using LCS.WPF.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace LCS.WPF.Views.Login
{
    public class LoginViewModel : ViewModelBase
    {

        public ICommand LoginCommand
        {
            set;
            get;
        }

        public ICommand ResetCommand
        {
            set;
            get;
        }


        public AccountApi AccountApi
        {
            set;
            get;
        }

        public LoginViewModel()
        {
            AccountApi = new AccountApi();
            LoginCommand = new RelayCommand(this.Login, this.CanLogin);
            ResetCommand = new RelayCommand(this.Reset, this.CanReset);
        }



        public async void Login()
        {

            var result = await AccountApi.Login(this.UserName, this.UserPassword);

            Console.WriteLine(result);

        }

        public bool CanLogin()
        {
            return (!string.IsNullOrWhiteSpace(this.UserName)) &&
                   (!string.IsNullOrWhiteSpace(this.UserPassword));
        }

        public void Reset()
        {

        }

        public bool CanReset()
        {
            return true;
        }


        private string userName;
        public string UserName
        {
            get { return userName; }
            set { userName = value; OnPropertyChanged("UserName"); }
        }

        private string userPassword;
        public string UserPassword
        {
            get { return userPassword; }
            set { userPassword = value; OnPropertyChanged("UserPassword"); }
        }



    }
}
